//
//  EAGLView.h
//  RnD_02_rolling_spheres
//
//  Created by Goffredo Marocchi on 7/22/10.
//  Copyright __MyCompanyName__ 2010. All rights reserved.
//

//
//  EAGLView.h
//  template
//
//  Created by SIO2 Interactive on 8/22/08.
//  Copyright SIO2 Interactive 2008. All rights reserved.
//

//File modified by Goffredo Marocchi (this is not the original SIO2 provided file,
//sio2 and its creator ROm are not responsible for the content of this file as it is now

#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

#import "sio2.h"

/// default gl blend src function
#define CC_BLEND_SRC GL_ONE
/// default gl blend dst function
#define CC_BLEND_DST GL_ONE_MINUS_SRC_ALPHA
#define ALPHA_BLENDING_ON() glEnable(GL_BLEND);glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST)
#define ALPHA_BLENDING_OFF() glDisable(GL_BLEND)

/*
 This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass.
 The view content is basically an EAGL surface you render your OpenGL scene into.
 Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
 */

@interface EAGLView : UIView {
	
@private
	/* The pixel dimensions of the backbuffer */
	GLint backingWidth;
	GLint backingHeight;
	
	EAGLContext *context;
	
	/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
	GLuint viewRenderbuffer, viewFramebuffer;
	
	/* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
	GLuint depthRenderbuffer;
	
	id displayLink;
	NSTimer *animationTimer;
	
	BOOL displayLinkSupported;
	BOOL isAnimating;
}

@property NSTimeInterval animationInterval;

- (void)startAnimation;
- (void)stopAnimation;
- (void)drawView;

- (CGSize)frame_size;

-(id) getDelegate;

@end
